package com.didispace.chapter56.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


/**
 * @ProjectName powerFind
 * @Package com.datago.robot.common.config
 * @Name WebConfigurer
 * @Author HB
 * @Date 2021/2/18 10:20
 * @Version 1.0
 */
@Configuration
public class WebConfigurer implements WebMvcConfigurer {

    LoginHandlerInterceptor loginInterceptor;

    @Autowired
    public void setLoginInterceptor(LoginHandlerInterceptor loginInterceptor) {
        this.loginInterceptor = loginInterceptor;
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // TODO Auto-generated method stub
        // addPathPatterns("/**") 表示拦截所有的请求，
        // excludePathPatterns("/login", "/register") 表示除了登陆与注册之外，因为登陆注册不需要登陆也可以访问
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/",
                        //登录接口
                        "/datagoUser/login",
                        //导出报名人员excel文件接口
                        "/file/**",
                        //展示活动照片接口
                        "/activityImage/**",

                        "/activity/getIsActivityCount",
                        "/activity/getActivityCount",
                        "/image/imageFileSave",
                        "/activity/importShowTemplate",
                        "/activity/templatePersonDownload",
                        "/honor/importShowTemplate",
                        "/honor/templatePersonDownload"
                );
    }

}
